﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:viewmodels="clr-namespace:Analyzer.ViewModels;assembly=Analyzer.ViewModels"
                    xmlns:views="clr-namespace:Analyzer.Views"                    
                    xmlns:model="clr-namespace:Analyzer.Models;assembly=Analyzer.Models">

    <viewmodels:ListIndexConverter x:Key="myListIndexConverter"/>

        <DataTemplate DataType="{x:Type viewmodels:EntityViewModel}">
        <views:EntityView/>
    </DataTemplate>
    
    <DataTemplate x:Key="TreeViewDataTemplate"
                  DataType="{x:Type viewmodels:AnalyzerItemViewModel}">
        <views:AnalyzerItemView/>        
    </DataTemplate>
    
    <DataTemplate DataType="{x:Type viewmodels:ItemLoadingViewModel}">
        <views:ItemLoadingView/>
    </DataTemplate>    
    
    <DataTemplate DataType="{x:Type model:ItemDetails}">
        <Border Margin="2" CornerRadius="5" 
                    BorderThickness="0" BorderBrush="Black">
            <StackPanel>
                <Image Source="Icons/pin.png" Height="20" Width="40" Margin="0,0,0,5"
                               VerticalAlignment="Top" DockPanel.Dock="Left"/>
                <TextBlock Margin="2" VerticalAlignment="Center"
                                   Foreground="Black" FontFamily="Buxton Sketch"
                                   Text="{Binding Details}" FontSize="17"/>
            </StackPanel>
            
        </Border>
    </DataTemplate>
   
    <DataTemplate x:Key="AccessControlDataTemplate" DataType="viewmodels:EntityViewModel">
        <Grid MinWidth="375">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <TextBlock Text="{Binding Identity, Source=AccessListDetails}" FontFamily="Buxton Sketch" FontSize="15" Foreground="Red" Grid.Column="0"/>
            <TextBlock Text="{Binding Control, Source=AccessListDetails}" FontFamily="Buxton Sketch" FontSize="15" Foreground="Red" Grid.Column="1"/>
            <TextBlock Text="{Binding Rights, Source=AccessListDetails}" FontFamily="Buxton Sketch" FontSize="15" Foreground="Red" Grid.Column="2"/>
        </Grid>        
    </DataTemplate>
    
    <viewmodels:ElementTypeToImageConverter x:Key="ElementTypeToImageConverter"/>

    <Style x:Key="TreeViewItemStyle" TargetType="{x:Type TreeViewItem}">
        <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
        <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
        <Setter Property="FontWeight" Value="Normal" />
        <Style.Triggers>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="FontWeight" Value="Bold" />
            </Trigger>
        </Style.Triggers>
    </Style>   
    
    <Storyboard x:Key="blinkAnimation" RepeatBehavior="Forever">
        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)">
            <DiscreteObjectKeyFrame KeyTime="0:0:1.80">
                <DiscreteObjectKeyFrame.Value>
                    <Visibility>Collapsed</Visibility>
                </DiscreteObjectKeyFrame.Value>
            </DiscreteObjectKeyFrame>
            <DiscreteObjectKeyFrame KeyTime="0:0:2">
                <DiscreteObjectKeyFrame.Value>
                    <Visibility>Visible</Visibility>
                </DiscreteObjectKeyFrame.Value>
            </DiscreteObjectKeyFrame>
        </ObjectAnimationUsingKeyFrames>
    </Storyboard>
    <Style x:Key="BlinkingTextBox" TargetType="TextBlock">
        <Style.Triggers>
            <EventTrigger RoutedEvent="Loaded">
                <BeginStoryboard Storyboard="{StaticResource blinkAnimation}"/>                
            </EventTrigger>
        </Style.Triggers>
    </Style>
    <Style x:Key="TextBlockStyle" TargetType="{x:Type TextBlock}">
        <Style.Triggers>
            <DataTrigger Binding="{Binding IsEnabled}" Value="False">              
                <Setter Property="Opacity" Value=".5"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="DockPanelStyle" TargetType="{x:Type DockPanel}">
        <!-- Property trigger - Reacts on WPF property-->
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="Firebrick"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="StackPanelStyle" TargetType="{x:Type StackPanel}">        
        <!-- Property trigger - Reacts on WPF property-->
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="Firebrick"/>
            </Trigger>            
        </Style.Triggers>
    </Style>
    
    <Style x:Key="StrikethroughStyle" TargetType="{x:Type TextBlock}">
        <Style.Triggers>
            <DataTrigger Binding="{Binding ElementType}" Value="Hidden">
                <Setter Property="TextDecorations" Value="strikethrough" /> 
            </DataTrigger>            
        </Style.Triggers>
    </Style>
    <Style TargetType="{x:Type DataGridRow}">
        <Style.Triggers>
            <Trigger Property="AlternationIndex" Value="2" >
                <Setter Property="Background" Value="Azure" />
            </Trigger>
            <Trigger Property="AlternationIndex" Value="3">
                <Setter Property="Background" Value="Azure" />
            </Trigger>
        </Style.Triggers>
    </Style>
    <Style x:Key="ChartBorderStyle" TargetType="Border">
        <Setter Property="Padding" Value="5" />
        <Setter Property="CornerRadius" Value="5" />
        <Setter Property="BorderBrush" Value="Gray" />
        <Setter Property="BorderThickness" Value="0.5" />
        <Setter Property="Background" Value="White" />
    </Style>
    <Style TargetType="ListBox">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden"/>
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <Canvas x:Name="canv" Width="200" Height="200" 
                                Background="Transparent" Margin="5" />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="ListBoxItem">
        <Setter Property="Canvas.Left" Value="0"/>
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>

        <Setter Property="Canvas.Top">
            <Setter.Value>
                <Binding RelativeSource="{RelativeSource Self}" 
                        Converter="{StaticResource myListIndexConverter}"
                        ConverterParameter="Top"/>
            </Setter.Value>
        </Setter>
        <Setter Property="Canvas.ZIndex">
            <Setter.Value>
                <Binding RelativeSource="{RelativeSource Self}" 
                        Converter="{StaticResource myListIndexConverter}"
                        ConverterParameter="ZIndex"/>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                    <Grid x:Name="gridItem" Background="DarkGoldenrod" MaxWidth="400">
                        <Border Background="LemonChiffon" Margin="2">
                            <ContentPresenter 
                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                    HorizontalAlignment="Stretch" 
                                    VerticalAlignment="Stretch" 
                                    Margin="0"/>
                        </Border>
                        <Grid.LayoutTransform>
                            <RotateTransform CenterX="0.5" CenterY="0.5" 
                                    Angle="{Binding RelativeSource=
                                    {RelativeSource Mode=FindAncestor, 
                                    AncestorType={x:Type ListBoxItem}, AncestorLevel=1}, 
                                    Converter={StaticResource myListIndexConverter}, 
                                    ConverterParameter='Rotate'}"/>
                        </Grid.LayoutTransform>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="true">
                            <Setter TargetName="gridItem" Property="RenderTransform">
                                <Setter.Value>
                                    <ScaleTransform CenterX="0.5" CenterY="0.5" 
                                                        ScaleX="1.5" ScaleY="1.5"/>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Canvas.ZIndex" Value="99999"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>